﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KCBF.Modules.AI.QuestSteps.Substeps;
using KCBF.Modules.AI.TreeSharp;

using D3;
using NYTBD;
using Action = KCBF.Modules.AI.TreeSharp.Action;

namespace KCBF.Modules.AI.QuestSteps
{

    class DestroyEnvironment : Decorator
    {

        private string _target;
        private bool _isDone = false;

        public void doStuff(){}

        public DestroyEnvironment(string target, float x = -1, float y = -1): base(null, null)
        {
            Runner = _Runner;

            _target = target;

            PrioritySelector myChild = new PrioritySelector();

            myChild.AddChild(new MoveToNpc(target));
            if (x > 0) myChild.AddChild(new Decorator(delegate(object a)
            {

                if (_Game.GetUnit(_target) == null)
                {
                    return true;
                }

                return false;
            }, new MoveToPosition(x, y)));
            myChild.AddChild(new CheckForNpc(_target));
            myChild.AddChild(new Substeps.DestroyEnvironment(_target));

            myChild.AddChild(new Action(delegate
            {

                _isDone = true;
            }));

            Children[0] = myChild;
        }

        private bool _Runner(object context)
        {
            return !_isDone;
        }
    }
}
